<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0,user-scalable=no">
    <title></title>
    <style media="screen">
    body {height:2000px;}
    .box {width:200px; height:200px; background:#CCC; border:1px solid black; position:absolute; line-height:200px; text-align:center; font-size:40px; left:50%; top:150px; margin-left:-100px; transform: rotate(0deg)}
    </style>
    <script>
    function calcAng(touch1, touch2){
      let x=touch1.clientX-touch2.clientX;
      let y=touch1.clientY-touch2.clientY;

      return Math.atan2(y, x)*180/Math.PI;
    }

    window.onload=function (){
      let oBox=document.getElementsByClassName('box')[0];

      let ang1,ang2;
      let ang=0,old_ang;

      document.addEventListener('touchstart', function (ev){
        if(ev.targetTouches.length>=2){
          ang1=calcAng(ev.targetTouches[0], ev.targetTouches[1]);
          old_ang=ang;
        }
      }, false);

      document.addEventListener('touchmove', function (ev){
        if(ev.targetTouches.length>=2){
          ang2=calcAng(ev.targetTouches[0], ev.targetTouches[1]);

          ang=old_ang+ang2-ang1;

          oBox.style.transform=`rotate(${ang}deg)`;
        }
      }, false);
    };
    </script>
  </head>
  <body>
    <input type="text" name="" value="">
    <input type="button" value="按钮" onclick="document.querySelector('.box').style.background='yellow';">
    <div class="box">asdfasdf</div>
  </body>
</html>
